package com.appcenter.application.mapper;

import com.appcenter.application.dto.users.UserAddrDto;
import com.appcenter.application.model.UserAddrs;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

@Repository
@org.apache.ibatis.annotations.Mapper
public interface UserAddrsMapper extends Mapper<UserAddrs> {




    @Select("select * from useraddrs where UserId=#{UserId}")
    UserAddrs getUserAddsByUserId(String UserId);



    @Delete("delete from useraddrs where userid=#{UserId}")
    public int deleteUserAddrByUserId(String UserId);

    @Select("SELECT *,NULL ProvinceName ,NULL CityName,NULL AreaName,NULL CreateTime FROM useraddrs order  by Id")
    List<UserAddrs> searchUserAddrList();

    @Select("SELECT *,NULL ProvinceName ,NULL CityName,NULL AreaName,NULL CreateTime FROM useraddrs where Id=#{Id}")
    UserAddrDto getUserAddrById(String Id);

    @Update("UPDATE  UserAddrs SET UserId=#{UserId}, ProvinceCode=#{ProvinceCode},CityCode=#{CityCode},AreaCode=#{AreaCode} WHERE Id=#{Id}")
    int editUserAddr( UserAddrDto input);


}
